package com.oscar.ehome.view.pageview;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.util.Util;
import com.oscar.ehome.MainActivity;
import com.oscar.ehome.R;
import com.oscar.ehome.base.AppManager;
import com.oscar.ehome.base.C;
import com.oscar.ehome.base.activity.BasesActivity;
import com.oscar.ehome.bean.pagebean.StudyDetialBean;
import com.oscar.ehome.presenter.PagePresenter;
import com.oscar.ehome.provider.gildeimage.GildeUtils;
import com.oscar.ehome.utils.basethem.TintManager;
import com.oscar.ehome.utils.database.DataBaseDAO;
import com.oscar.ehome.utils.dowload.dowload.DownloadManager;
import com.oscar.ehome.utils.dowload.dowload.OnDownload;
import com.oscar.ehome.utils.dowload.entity.FileInfo;
import com.oscar.ehome.utils.dowload.progressbar.RoundProgressBar;
import com.oscar.ehome.utils.system.SystemConfigFactory;
import com.oscar.ehome.utils.util.CommonUtils;
import com.oscar.ehome.utils.util.ToastUtil;
import com.oscar.ehome.utils.util.makeTime;
import com.oscar.ehome.utils.view.progressview.ProgressFrameLayout;
import com.oscar.ehome.view.loginview.LoginActivity;
import com.oscar.ehome.view.pageview.view.StudyDetialView;
import com.yanzhenjie.album.Album;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by oscar
 * author: MengWanhe
 * date: On 2017/7/12
 * pdf详情
 */

public class PdfDetialActivity extends BasesActivity<StudyDetialView, PagePresenter> implements StudyDetialView, ProgressFrameLayout.AgainRequestListener {

    /**
     * 返回
     */
    @BindView(R.id.title_img_back)
    ImageView titleImgBack;
    /**
     * 返回
     */
    @BindView(R.id.title_layout_left)
    RelativeLayout titleLayoutLeft;
    /**
     * 标题
     */
    @BindView(R.id.title_topbar)
    TextView titleTopbar;
    /**
     * 标题
     */
    @BindView(R.id.pdf_title)
    TextView pdfTitle;
    /**
     * 作者
     */
    @BindView(R.id.pdf_author)
    TextView pdfAuthor;
    /**
     * 时间
     */
    @BindView(R.id.pdf_time)
    TextView pdfTime;
    /**
     * 在线阅读
     */
    static Button pdfOnlineread;
    /**
     * 下载按钮
     */
    static ImageView pdfDownload;
    /**
     * 内容
     */
    @BindView(R.id.pdf_content)
    TextView pdfContent;
    @BindView(R.id.title_tv_right)
    TextView title_tv_right;
    /**
     * title布局
     */
    @BindView(R.id.basetitle_bar)
    RelativeLayout basetitleBar;
    /**
     * 进度
     */
    static RoundProgressBar pdfRoundProgressBar;

    @BindView(R.id.pdfs_fragment)
    FrameLayout pdfsFragment;

    @BindView(R.id.pdf_fragment)
    ProgressFrameLayout pdfFragment;
    /**
     * 图片
     */
    @BindView(R.id.pdf_img)
    ImageView pdfImg;

    public String id = "";
    public String token = "";

    public PagePresenter pagePresenter;
    /**
     * 下载的文件详情
     */
    public FileInfo info;

    public String videoUrl = "";//下载地址
    public String fileName = "";//文件名字
    public static String ids = "";//文件ID
    public static String pdf_id = "";//文件ID
    public int dowload = 0;//下载状态
    public String localPath = "";//文件存放路径
    String startime = "";//开始时间
    String endtime = "";//结束时间
    String time = "";//秒数
    int fin = 0;//是否关闭页面
    private TimeCount timeCount;
    String title = "", type = "",open="";//存入数据库的标题
    String imgdata = "";//存入数据库的图片
    DataBaseDAO dataBaseDAO;//数据库


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pdfdetail);
        ButterKnife.bind(this);
        initView();
        setColor();
        initData();
    }

    /**
     * 设置颜色
     */
    public void setColor() {
        basetitleBar.setBackgroundColor(Color.parseColor(SystemConfigFactory.getInstance(PdfDetialActivity.this).getSystemConfig().getColor()));
        TintManager.setTint(pdfDownload, Color.parseColor(SystemConfigFactory.getInstance(this).getSystemConfig().getColor()));

    }

    /**
     * 倒计时
     */
    class TimeCount extends CountDownTimer {
        public TimeCount(long millisInFuture, long countDownInterval) {
            super(millisInFuture, countDownInterval);//参数依次为总时长,和计时的时间间隔
        }

        @Override
        public void onFinish() {//计时完毕时触发
            title_tv_right.setText("完成");
            title_tv_right.setClickable(true);
        }

        @Override
        public void onTick(long millisUntilFinished) {//计时过程显示
            title_tv_right.setClickable(false);
            title_tv_right.setText("完成("+millisUntilFinished / 1000 + "秒)");
        }
    }


    public void initView() {
        pdfRoundProgressBar = (RoundProgressBar) findViewById(R.id.pdf_roundProgressBar);
        pdfDownload = (ImageView) findViewById(R.id.pdf_download);
        pdfOnlineread = (Button) findViewById(R.id.pdf_onlineread);

        Intent in = getIntent();
        id = getIntent().getStringExtra("id");
        open=getIntent().getStringExtra("open");
        if (in.getStringExtra("type") != null && in.getStringExtra("type").equals("qiangzhi")) {
            type = in.getStringExtra("type");
            titleImgBack.setVisibility(View.GONE);
            title_tv_right.setVisibility(View.VISIBLE);
            timeCount = new TimeCount(60000, 1000);
            timeCount.start();
        } else {
            if(open!=null&&open.equals("ture")){
                title_tv_right.setVisibility(View.VISIBLE);
                title_tv_right.setText("发送");
                titleImgBack.setVisibility(View.VISIBLE);
                titleImgBack.setImageResource(R.mipmap.fanhui);
            }else{
                title_tv_right.setVisibility(View.GONE);
                titleImgBack.setVisibility(View.VISIBLE);
                titleImgBack.setImageResource(R.mipmap.fanhui);
            }


        }


        titleTopbar.setText("PDF");

        token = SystemConfigFactory.getInstance(PdfDetialActivity.this).getSystemConfig().getToken();
        startime = makeTime.mtime();
        dataBaseDAO = new DataBaseDAO(PdfDetialActivity.this);

        // pdfRoundProgressBar.setVisibility(View.GONE);
        //  pdfDownload.setVisibility(View.VISIBLE);
        if(open!=null&&open.equals("ture")){
            localPath = CommonUtils.getSDCardRootPath() + C.video;// 文件存储路径，sd卡路径
            Log.e("pdfchazhao", "initView: "+ CommonUtils.getSDCardRootPath() + C.video);
        }else{
            localPath = CommonUtils.getSDCardRootPath(PdfDetialActivity.this) + C.video;// 文件存储路径，sd卡路径
            Log.e("pdfchazhao", "initView: "+ CommonUtils.getSDCardRootPath(PdfDetialActivity.this) + C.video);

        }


        pdfOnlineread.setTextColor(Color.parseColor(SystemConfigFactory.getInstance(PdfDetialActivity.this).getSystemConfig().getColor()));
        GradientDrawable drawable = (GradientDrawable) pdfOnlineread.getBackground();
        //改变drawable的背景填充色
        drawable.setStroke(3, Color.parseColor(SystemConfigFactory.getInstance(PdfDetialActivity.this).getSystemConfig().getColor()));
        pdfFragment.setAgainRequestListener(this);
    }

    /**
     * 未开始下载的状态
     */
    public void undowload() {
        if(open!=null&&open.equals("ture")){
            if (CommonUtils.GetVideoFileName(CommonUtils.getSDCardRootPath() + C.video + fileName)) {// 已下载
                dowload = 1;
                pdfDownload.setImageResource(R.mipmap.duigou);
                pdfDownload.setEnabled(false);
                TintManager.setTint(pdfDownload, Color.parseColor(SystemConfigFactory.getInstance(this).getSystemConfig().getColor()));
            } else {
                // 未下载
                dowload = 0;
            }
            if (CommonUtils.isPdf == 1) {
                if (pdf_id.equals(ids)) {
                    dowload = 3;
                    //   pdfRoundProgressBar.setVisibility(View.VISIBLE);
                    pdfDownload.setVisibility(View.GONE);
                }
            }
        }else{
            if (CommonUtils.GetVideoFileName(CommonUtils.getSDCardRootPath(PdfDetialActivity.this) + C.video + fileName)) {// 已下载
                dowload = 1;
                pdfDownload.setImageResource(R.mipmap.duigou);
                pdfDownload.setEnabled(false);
                TintManager.setTint(pdfDownload, Color.parseColor(SystemConfigFactory.getInstance(this).getSystemConfig().getColor()));
            } else {
                // 未下载
                dowload = 0;
            }
            if (CommonUtils.isPdf == 1) {
                if (pdf_id.equals(ids)) {
                    dowload = 3;
                    //   pdfRoundProgressBar.setVisibility(View.VISIBLE);
                    pdfDownload.setVisibility(View.GONE);
                }
            }
        }

    }

    /**
     * 加载数据
     */
    public void initData() {
        pagePresenter.getStudyDetial(token, id);
        showLoading();
    }

    /**
     * 加载数据
     */
    public void saveData() {
        fin = 2;
        time = makeTime.getDistanceTime(Long.parseLong(startime), Long.parseLong(endtime));
        pagePresenter.saveLearn(token, id, startime, endtime, time);
    }

    @OnClick({R.id.title_layout_left, R.id.pdf_onlineread, R.id.pdf_download,R.id.title_tv_right})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_tv_right://返回
                if(title_tv_right.getText().equals("完成")){
                    if(dowload==4){
                        dowload_file();
                    }
                    if (videoUrl != null && !"".equals(videoUrl)) {
                        endtime = makeTime.mtime();
                        saveData();
                    } else {
                        Intent intent;
                        intent = new Intent(PdfDetialActivity.this, MainActivity.class);
                        intent.putExtra("intent", 1);
                        startActivity(intent);
                        finish();
                    }
                }else if(title_tv_right.getText().equals("发送")){
                    Log.e("pdfchazhao", "initView: "+ "1");

                    if(GetVideoFileName(localPath+fileName)){
                        new PopupWindows(PdfDetialActivity.this, title_tv_right);
                    }else{
                        ToastUtil.show(PdfDetialActivity.this,"文件未下载，请点击在线阅读进行下载。");
                    }

                }else{
                    ToastUtil.show(PdfDetialActivity.this, "请倒计时结束后点击退出");
                }

//                finish();
                break;
            case R.id.title_layout_left://返回
                if (videoUrl != null && !"".equals(videoUrl)) {
                    endtime = makeTime.mtime();
                    saveData();
                } else {
                    finish();
                }

//                finish();
                break;
            case R.id.pdf_onlineread://在线阅读
                if (dowload == 0) {
                    dowload_file();
                }
                Intent intent = new Intent(PdfDetialActivity.this, PdfActivity.class);
                if(open!=null&&open.equals("ture")){
                    intent.putExtra("open", "ture");
                }else{
                    intent.putExtra("open", "false");
                }
                if (dowload == 1) {// 已下载
                    intent.putExtra("url", "1");
                } else {
                    intent.putExtra("url", videoUrl);
                }
                intent.putExtra("fileName", fileName);
                Log.e("1234ss56", "onViewClicked: "+videoUrl+fileName );

                startActivity(intent);
                break;
            case R.id.pdf_download://下载
                switch (dowload) {
                    case 0://未下载
//                        if (CommonUtils.isVideo == 1 || CommonUtils.isFrec == 1) {
//                            ToastUtil.show(PdfDetialActivity.this, R.string.dowloading);
//                        } else {
//                            dowload_file();
//                        }
                        dowload_file();
                        break;
                    case 1://已下载
                        ToastUtil.show(PdfDetialActivity.this, R.string.dowload_file);
                        break;
                    case 3://正在下载，点击暂停
                        puseDowload_file();
                        break;
                    case 4://暂停中，点击继续下载
                        dowload_file();
                        break;
                }
                break;
            case R.id.pdf_roundProgressBar://暂停
                switch (dowload) {
                    case 1://已下载
                        ToastUtil.show(PdfDetialActivity.this, R.string.dowload_file);
                        break;
                    case 3://正在下载，点击暂停
                        puseDowload_file();
                        break;
                    case 4://暂停中，点击继续下载
                        dowload_file();
                        break;
                }
                break;
        }
    }
    public boolean GetVideoFileName(String fileAbsolutePath) {
        File dstDiretory = new File(fileAbsolutePath);
        if (dstDiretory.exists()) {// 目标目录不存在
            return true;
        }
        return false;
    }
    @Override
    public void getstudyDetail(StudyDetialBean result) {
        dismissLoading();
        if (result != null) {
            pdfFragment.stopRefresh();
            pdfsFragment.setVisibility(View.VISIBLE);

            title = result.getTitle();
            pdfTitle.setText(result.getTitle());
            pdfAuthor.setText(result.getCreateBy().getName());
            pdfTime.setText(result.getUpdateDate());
            pdfContent.setText(result.getRemarks());
            imgdata = C.qiniu_ip + result.getSmallImg();
            videoUrl = C.qiniu_ip + result.getMediaFile();
//            GildeUtils.imgLoadPic(PdfDetialActivity.this, imgdata, pdfImg, "net");
            GildeUtils.loadUrlImages(imgdata, pdfImg, PdfDetialActivity.this);
            fileName = result.getMediaFile();
            undowload();
        }
    }

    @Override
    public void saveLearn(String result) {
        if (fin == 2) {
            if(type!=null&&type.equals("qiangzhi")){
                Intent intent;
                intent = new Intent(PdfDetialActivity.this, MainActivity.class);
                intent.putExtra("intent", 1);
                startActivity(intent);
                finish();
            }else{
                finish();
            }
        }
    }

    @Override
    public void erroy() {
        dismissLoading();
        pdfFragment.setNoResult();
        pdfFragment.setVisibility(View.VISIBLE);
        pdfsFragment.setVisibility(View.GONE);
        ToastUtil.show(PdfDetialActivity.this, getString(R.string.erry));
        if (fin == 2) {
            finish();
        }
    }

    @Override
    public void erry(String result) {
        dismissLoading();
        pdfFragment.setNoResult();
        pdfFragment.setVisibility(View.VISIBLE);
        pdfsFragment.setVisibility(View.GONE);
        Toast.makeText(PdfDetialActivity.this, result, Toast.LENGTH_SHORT).show();
        if (result.contains("过期")) {
            getSharedPreferences("appbase", Context.MODE_PRIVATE).edit().clear().commit();
            SystemConfigFactory.getInstance(PdfDetialActivity.this).getSystemConfig().SetLogin(false);
            SystemConfigFactory.getInstance(this).getSystemConfig().setIsFirst(true);
            Intent intent = new Intent(PdfDetialActivity.this, LoginActivity.class);
            startActivity(intent);
            finish();
        }
    }

    /**
     * 下载文件的方法
     */
    public void dowload_file() {
        // 下载
        int info_id = 1;
        // pdfRoundProgressBar.setVisibility(View.VISIBLE);
        pdfDownload.setVisibility(View.GONE);

        info = new FileInfo(info_id, videoUrl, fileName, 0, 0);
        final OnDownloadImpl impl = new OnDownloadImpl(pdfRoundProgressBar, 0);
        DownloadManager.instance(PdfDetialActivity.this).startDownload(info.getUrl(), localPath, fileName, impl,
                ids, pdfRoundProgressBar); // 开始下载
        // ToastUtil.show(PdfDetialActivity.this, "开始下载");

        dowload = 3;
    }

    /**
     * 暂停文件的方法
     */
    public void puseDowload_file() {
        dowload = 4;
        int info_id = 1;
        info = new FileInfo(info_id, videoUrl, 0, 0);
        DownloadManager.instance(PdfDetialActivity.this).pauseDownload(info.getUrl());
        pdfRoundProgressBar.setVisibility(View.GONE);
        // pdfDownload.setVisibility(View.VISIBLE);

        pdfDownload.setImageResource(R.mipmap.zanting);
        TintManager.setTint(pdfDownload, Color.parseColor(SystemConfigFactory.getInstance(PdfDetialActivity.this).getSystemConfig().getColor()));
    }

    @Override
    public void againRequest() {

    }

    /**
     * 下载回调监听类
     */
    class OnDownloadImpl implements OnDownload {
        public RoundProgressBar pb; // 进度条
        public int position; // 列表位置

        public OnDownloadImpl(RoundProgressBar pb, int posision) {
            this.pb = pb;
            this.position = posision;
        }

        /**
         * 下载中
         */
        @Override
        public void onDownloading(String retUrl, int finished, String bookid, RoundProgressBar pb) {
            pdf_id = bookid;
            if (ids.equals(bookid)) {
                if (dowload == 3) {// 下载中
                    // pdfRoundProgressBar.setVisibility(View.VISIBLE);
                    pdfDownload.setVisibility(View.GONE);
                    CommonUtils.isPdf = 1;
                    pdfRoundProgressBar.setProgress(finished);
                } else if (dowload == 4) {// 暂停
                    // 缓存的暂停的id和此文件的id相同的话点击此按钮直接继续下载,同时移除缓存的此文件id
                    pdfRoundProgressBar.setVisibility(View.GONE);
                    //    pdfDownload.setVisibility(View.VISIBLE);
                }
            }
        }

        /**
         * 下载完成
         */
        @Override
        public void onDownloadFinished(File downloadFile, int isfinshed) {
            //ToastUtil.show(PdfDetialActivity.this, "下载完成");
            pdfRoundProgressBar.setProgress(100);
            pdfRoundProgressBar.setVisibility(View.GONE);
            //  pdfDownload.setVisibility(View.VISIBLE);
            pdfDownload.setImageResource(R.mipmap.duigou);
            pdfDownload.setEnabled(false);
            TintManager.setTint(pdfDownload, Color.parseColor(SystemConfigFactory.getInstance(PdfDetialActivity.this).getSystemConfig().getColor()));

            String sizes = CommonUtils.getFileOrFilesSize(localPath + fileName, 3);
            Log.e("5652525", "initView: "+localPath+fileName);
            if (dowload != 1) {
                //插入数据库
                Map<String, Object> datas = new HashMap<String, Object>();// 存储
                datas.put("title", title);
                if (imgdata == null) {
                    imgdata = "";
                }
                datas.put("imgdata", imgdata);
                datas.put("size", sizes);
                datas.put("filename", fileName);
                datas.put("learnType", "application/pdf");
                datas.put("ids", id);
                dataBaseDAO.insert("fileDownload", datas);
            }
            dowload = 1;
            CommonUtils.isPdf = 0;
        }

        /**
         * 是否连接网络
         */
        @Override
        public void onNetwork(boolean flag) {// 判断是否有网络
            // TODO Auto-generated method stub
            if (!flag) {// 无网络时
                // 暂停下载
                puseDowload_file();
            } else {// 暂停中 ，开始下载
                dowload_file();
            }
        }

        @Override
        public void onStrartDownloading(String url, String bookid) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onErroy(String bookid) {
            // TODO Auto-generated method stub
            if (ids.equals(bookid)) {
                ToastUtil.show(PdfDetialActivity.this, "下载失败");
                pdfRoundProgressBar.setVisibility(View.GONE);
                //   pdfDownload.setVisibility(View.VISIBLE);
                dowload = 0;
            }
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if(type.equals("qiangzhi")){
                AppManager appManager = AppManager.getAppManager();
                appManager.finishAllActivity();
                finish();
            }else {
                endtime = makeTime.mtime();
                if (videoUrl != null && !"".equals(videoUrl)) {
                    saveData();
                } else {
                    finish();
                }
            }
            return false;
        }
        return super.onKeyDown(keyCode, event);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (Util.isOnMainThread() && !this.isFinishing()) {
            Glide.with(this).pauseRequests();
        }
    }

    @Override
    protected PagePresenter createPresenter() {
        pagePresenter = new PagePresenter(this);
        return pagePresenter;
    }

    public class PopupWindows extends PopupWindow {

        public PopupWindows(Context mContext, View parent) {

            View view = View.inflate(mContext, R.layout.fenxiangbuju, null);
            view.startAnimation(AnimationUtils.loadAnimation(mContext,
                    R.anim.fade_ins));
            LinearLayout ll_popup = (LinearLayout) view
                    .findViewById(R.id.ll_popup);
            ll_popup.startAnimation(AnimationUtils.loadAnimation(mContext,
                    R.anim.push_bottom_in_2));

            setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
            setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
            setFocusable(true);
            setOutsideTouchable(true);
            setContentView(view);
            showAtLocation(parent, Gravity.BOTTOM, 0, 0);
            update();
            Button bt1 = (Button) view
                    .findViewById(R.id.item_popupwindows_Photo);
            Button bt2 = (Button) view
                    .findViewById(R.id.item_popupwindows_qq);
            Button bt3 = (Button) view
                    .findViewById(R.id.item_popupwindows_center);
            bt1.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {

                    Intent sendIntent = new Intent();
                    sendIntent.setAction(Intent.ACTION_SEND);
                    Log.e("pdfchazhao", "initView: "+ localPath+fileName);
                    File f = new File(localPath+fileName);
                    sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
                    sendIntent.setType("*/*");
                    sendIntent.setClassName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareImgUI");//微信朋友
//          sendIntent.setClassName("com.tencent.mobileqq", "cooperation.qqfav.widget.QfavJumpActivity");//保存到QQ收藏
//          sendIntent.setClassName("com.tencent.mobileqq", "cooperation.qlink.QlinkShareJumpActivity");//QQ面对面快传
//          sendIntent.setClassName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.qfileJumpActivity");//传给我的电脑
                    //sendIntent.setClassName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity");//QQ好友或QQ群
//          sendIntent.setClassName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareToTimeLineUI");//微信朋友圈，仅支持分享图片
                    startActivity(sendIntent );


                    dismiss();

                }
            });
            bt2.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {

                    Intent sendIntent = new Intent();
                    sendIntent.setAction(Intent.ACTION_SEND);
                    Log.e("pdfchazhao", "initView: "+ localPath+fileName);
                    File f = new File(localPath+fileName);
                    sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
                    sendIntent.setType("*/*");
                   // sendIntent.setClassName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareImgUI");//微信朋友
//          sendIntent.setClassName("com.tencent.mobileqq", "cooperation.qqfav.widget.QfavJumpActivity");//保存到QQ收藏
//          sendIntent.setClassName("com.tencent.mobileqq", "cooperation.qlink.QlinkShareJumpActivity");//QQ面对面快传
//          sendIntent.setClassName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.qfileJumpActivity");//传给我的电脑
                    sendIntent.setClassName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity");//QQ好友或QQ群
//          sendIntent.setClassName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareToTimeLineUI");//微信朋友圈，仅支持分享图片
                    startActivity(sendIntent );


                    dismiss();

                }
            });
            bt3.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    dismiss();
                }
            });
        }
    }
}
